package com.mbds.utils;

import java.util.Arrays;
import java.util.List;
import java.util.Timer;

public class DataCollectionTimer {
	List<Abs_Task> tasks;
	
	public DataCollectionTimer(Abs_Task...tasks) {
		this.tasks = Arrays.asList(tasks);
		Timer timer = new Timer();

		for (Abs_Task t : this.tasks) {
			timer.schedule(t, 0,t.getDelay());
		}
	}
	
	public void stopTasks() {
		startStopTask(true);
	}
	
	public void startTasks() {
		startStopTask(false);
	}

	private void startStopTask(boolean b) {
		for (Abs_Task t : tasks) {
			t.setCancel(b);
		}
	}
	

}
